<template>
    <div class="user-info-container">
        <div class="user-profile">
            <div class="user-dyQDDS">
                <img :src="userInfo.avatar" alt="用户头像" class="user-avatar" />
                <div class="user-details">
                    <h2 class="user-name">{{ userInfo[language.username] }}</h2>
                    <div class="user-meta">
                        <img style="width: 50px; height: 18px;" :src="levelType[userInfo.tierLevel]" alt="">
                        <!-- <img style="width: 50px; height: 18px;" src="@/utils/vip/vip15_14px.webp" alt=""> -->
                        <!-- <a-tag :color="levelcolorType[userInfo.tierLevel]">VIP{{ userInfo.tierLevel }}</a-tag> -->
                        <div v-html="verify"></div>
                        <div v-html="secureLev"></div>
                        <!-- <a-tag :color="statusColorType[userInfo.verified]">{{ statusType[userInfo.verified] || '未认证'
                            }}</a-tag>
                        <a-tag :color="riskColorType[userInfo.safeLevel]">
                            <template #icon>
                                <safety-outlined />
                            </template>
{{ riskType[userInfo.safeLevel] || '低' }}
</a-tag> -->
                        <!--
            <span class="user-level"></span>
            <span class="user-status"></span>
            <span class="user-risk"></span> -->
                    </div>
                </div>
            </div>
            <div class="sc-8ffb102a-2 dyEOQi">
                <svg data-icon-id="icon-a-14px-line-xiajiantou" data-icon-group="GateEarn" data-icon-version="0.8.51"
                    viewBox="0 0 1024 1024" width="14px" height="14px" style="display: block;">
                    <path
                        d="M186.514286 334.774857a43.885714 43.885714 0 0 1 62.025143-0.219428L512 596.406857l263.460571-261.851428a43.885714 43.885714 0 1 1 61.878858 62.317714l-294.4 292.571428a43.885714 43.885714 0 0 1-61.878858 0l-294.4-292.571428a43.885714 43.885714 0 0 1-0.219428-62.098286z"
                        fill="currentColor"></path>
                </svg>
            </div>
        </div>

        <div class="user-info">
            <div class="info-item">
                <div class="info-label">UID</div>
                <div class="info-value">{{ userInfo.uident }}</div>
            </div>
            <div class="info-item">
                <div class="info-label">{{ language.fees }}</div>
                <div href="#" class="info-link">{{ language.manage }} ></div>
            </div>
            <div class="info-item">
                <div class="info-label">{{ language.phone }}</div>
                <div class="info-value">{{ `${userInfo.phone.slice(0, 3)}***${userInfo.phone.slice(-1)}` || '--' }}
                </div>
            </div>
            <div class="info-item">
                <div class="info-label">{{ language.email }}</div>
                <div class="info-value">{{ userInfo.hideName || '--' }}</div>
            </div>
            <div class="info-item">
                <div class="info-label">{{ language.thirdPartyLogin }}</div>
                <div href="#" class="info-link">{{ language.manage }} ></div>
            </div>
        </div>
    </div>
</template>

<script>
import { userInfo } from '@/data/mockData.js';
import { statusType, riskType, levelcolorType, statusColorType, riskColorType, levelType } from '@/utils/constant.js';
// import { Tag } from 'ant-design-vue';
// import { SafetyOutlined } from '@ant-design/icons-vue';
import { language } from '@/content-scripts/locales';

export default {
    name: "PersonInfo",
    components: {
        // ATag: Tag
        // SafetyOutlined
    },
    data() {
        return {
            isVisible: true,
            userInfo: userInfo,
            levelType: levelType,
            levelcolorType: levelcolorType,
            statusType: statusType,
            statusColorType: statusColorType,
            riskType: riskType,
            riskColorType: riskColorType,
            language: language,
            verify: null,
            secureLev: null
        };
    },
    created() {
        this.getPersonBasic()
        this.getPersonElement()
        console.log(language, 'wwwwweeeeeqpersonlang');

    },
    mounted() {

    },
    methods: {
        getPersonElement() {
            const verifidOne = document.querySelectorAll('.mantine-1xwt3gw')
            const verifidTwo = document.querySelectorAll('.mantine-1rc8e3v')
            const verifid = [...verifidOne, ...verifidTwo]
            console.log(verifid, 'verifidverifidverifid');
            console.log(verifid[0], 'verifidverifidverifid');
            if (verifid) {
                this.verify = verifid[0].outerHTML
            }


            const secureLevOne = document.querySelectorAll('.mantine-1kdy5e3')
            const secureLevTwo = document.querySelectorAll('.mantine-1rc8e3v')
            const secureLev = [...secureLevOne, ...secureLevTwo]
            console.log(secureLev, 'secureLevsecureLevsecureLev');

            if (secureLev) {
                if (secureLev.length == 1) {
                    this.secureLev = secureLev[0].outerHTML
                } else {
                    this.secureLev = secureLev[1].outerHTML
                }

            }
        },
        getPersonBasic() {
            this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
            console.log(this.userInfo, 'thissssssssssssss.usernnnnnnnnnn');
            console.log(this.userInfo.avatar, 'thissssssssssssss.usernnnnnnnnnn');

        },
        injectStyles() {
            const style = document.createElement('style');
            style.textContent = `
          .my-user-info-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 9999;
            display: flex;
            justify-content: center;
            align-items: center;
          }
        `;
            document.head.appendChild(style);
        },
        observePageChanges() {
            // 监听URL变化
            const observer = new MutationObserver(() => {
                if (window.location.href.includes('gate.io/zh/myaccount/profile')) {
                    this.isVisible = true;
                } else {
                    this.isVisible = false;
                }
            });

            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
        },
        handleRateManagement() {
            console.log("管理费率");
            // 实现费率管理逻辑
        },
        handleThirdPartyManagement() {
            console.log("管理第三方登录");
            // 实现第三方登录管理逻辑
        }
    }
};
</script>

<style scoped>
.user-info-container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    background-color: #fff;
    padding: 15px 0;
    border-radius: 8px;
    /* box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); */
    width: 100%;
    /* max-width: 2156px; */
}

.user-profile {
    /* width: 22%; */
    /* flex-grow: 1; */
    display: flex;
    margin-right: 12px;
    align-items: center;
    /* margin-bottom: 20px; */
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-right: 50px;
}

.user-details {
    display: flex;
    flex-direction: column;
    /* width: 80%; */
}



.user-name {
    font-size: 18px;
    font-weight: bold;
    margin: 0;
}

.user-meta {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.user-level,
.user-status,
.user-risk {
    font-size: 14px;
    color: #666;
}

.user-info {
    flex-grow: 14;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    /* width:100%; */
}

.info-item {
    display: flex;
    /* align-items: center; */
    flex-direction: column;
    gap: 8px;
    margin-right: 12px;
    min-width: 50px;
    flex: 1 1 auto;
    font-size: 14px;
    color: #8e949e;
    font-weight: bold;
}

.info-value {
    font-size: 16px;
    font-weight: 400;
    color: #262933;
}

.info-link {
    font-size: 16px;
    font-weight: 400;
    color: #262933;
}

.info-link:hover {
    text-decoration: underline;
}

.dyEOQi {
    display: none;
}

.user-dyQDDS {
    display: flex;
    align-items: center;
    padding-right: 20px;
    border-right: #ddd solid 1px;
}

@media screen and (max-width: 992px) {
    .user-info-container {
        display: block;
    }

    .user-profile {
        width: 100%;
        /* flex-grow: 1; */
        display: flex;
        align-items: center;
        justify-content: space-between;
        /* margin-bottom: 20px; */
    }

    .user-info {
        display: flex;
        flex-direction: column;
    }

    .dyEOQi {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        color: #262933;
        transition: transform 300ms ease 0s;
        transform: rotate(180deg);
    }

    .info-item {
        width: 100%;
        margin: 12px 0;
        flex-direction: row;
        -webkit-box-pack: justify;
        justify-content: space-between;
    }
}
</style>